<html>
<head><meta charset="utf-8"><title>GPUs, SIMD, and ABIs · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html">GPUs, SIMD, and ABIs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227331089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227331089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227331089">(Feb 22 2021 at 20:20)</a>:</h4>
<p>Well, I should clearly speak more authoritatively about the need for us to play nicely with GPU paradigms because people are straight-up just using rustc to emit SPIRV code for GPUs already with <code>#[repr(simd)]</code> types, I guess!</p>
<p>So we already know about the Vec3 issue. <a href="https://github.com/rust-lang/stdsimd/issues/63#issuecomment-783205841">https://github.com/rust-lang/stdsimd/issues/63#issuecomment-783205841</a><br>
But also, <span class="user-mention" data-user-id="224471">@Lokathor</span> what? <a href="https://github.com/rust-lang/rust/issues/81996#issuecomment-782232818">https://github.com/rust-lang/rust/issues/81996#issuecomment-782232818</a></p>



<a name="227332908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227332908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227332908">(Feb 22 2021 at 20:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs/near/227331089">said</a>:</p>
<blockquote>
<p>But also, <span class="user-mention silent" data-user-id="224471">Lokathor</span> what? <a href="https://github.com/rust-lang/rust/issues/81996#issuecomment-782232818">https://github.com/rust-lang/rust/issues/81996#issuecomment-782232818</a></p>
</blockquote>
<p>Ooh, are we getting architecture-independent type layout? That would let me just define a <code>struct</code> and know for certain that I can just write it to a network socket and read it from a totally different kind of computer, assured that after byteswapping, it will have the same values? Sounds awesome!<br>
Also handy for things like communication in a shared-memory computer with both RISC-V and PowerPC cores (which I've wanted to build).</p>



<a name="227333087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227333087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227333087">(Feb 22 2021 at 20:35)</a>:</h4>
<blockquote>
<p>That's often not true anymore (though it was usually true in the distant past, for OpenGL 2.x hardware), AMD's GPUs convert all vector operations to scalar operations on each SIMT thread iirc. So, a vec3 will just become 3 separate f32 variables.</p>
</blockquote>
<p><em>takes a drink</em></p>



<a name="227334353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334353">(Feb 22 2021 at 20:45)</a>:</h4>
<p>not all GPU data is simd</p>



<a name="227334474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334474">(Feb 22 2021 at 20:46)</a>:</h4>
<p>fair enough!</p>



<a name="227334479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334479">(Feb 22 2021 at 20:46)</a>:</h4>
<p>or to look at it another way: all gpu data is simd (whether you program it as simd or not)</p>



<a name="227334510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334510">(Feb 22 2021 at 20:47)</a>:</h4>
<p>there are versioned standards, usually from GLSL, and they precisely define the exact layout of each field, size/align i mean</p>



<a name="227334597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334597">(Feb 22 2021 at 20:47)</a>:</h4>
<p>yes also your program doesn't execute like you think it does from the text on the page</p>



<a name="227334757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334757">(Feb 22 2021 at 20:48)</a>:</h4>
<p>oh yeah, I already knew that part.</p>



<a name="227334796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334796">(Feb 22 2021 at 20:49)</a>:</h4>
<p>basically if repr C is going to chase the local C compiler then we need something stable that chases nothing</p>



<a name="227334817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334817">(Feb 22 2021 at 20:49)</a>:</h4>
<p>agreed.</p>



<a name="227334882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334882">(Feb 22 2021 at 20:49)</a>:</h4>
<p>Wait, repr(C) is different for SPIR-V?</p>



<a name="227334904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334904">(Feb 22 2021 at 20:49)</a>:</h4>
<p>I think repr(C) should not chase the local C compiler unless all the C compilers agree on being buggy, lol, at which point we might as well sigh and join up.</p>



<a name="227334910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334910">(Feb 22 2021 at 20:49)</a>:</h4>
<p>I thought C was pretty clear on layout?</p>



<a name="227334986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227334986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227334986">(Feb 22 2021 at 20:50)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> WELCOME TO THE TRUE HORRORS OF THE ABYSS</p>



<a name="227335042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335042">(Feb 22 2021 at 20:50)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> see the start of the issue linked at the top of this thread</p>



<a name="227335045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335045">(Feb 22 2021 at 20:50)</a>:</h4>
<p>You're not wrong</p>



<a name="227335051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335051">(Feb 22 2021 at 20:50)</a>:</h4>
<p>There's a few different conversations going on here.</p>



<a name="227335432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335432">(Feb 22 2021 at 20:53)</a>:</h4>
<p>Ok, so if I got this right, repr(C) is usually right because the C compiler is usually right, but sometimes it's not</p>



<a name="227335534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335534">(Feb 22 2021 at 20:54)</a>:</h4>
<p>Yes.<br>
<span class="user-mention" data-user-id="224471">@Lokathor</span> I guess my question is how exactly is the GPU code using <code>repr(C)</code>?</p>



<a name="227335726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335726">(Feb 22 2021 at 20:55)</a>:</h4>
<p>repr C is the only repr allowed if you're pushing a struct out to ffi</p>



<a name="227335751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335751">(Feb 22 2021 at 20:55)</a>:</h4>
<p>ahhh OK, I see now.</p>



<a name="227335852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335852">(Feb 22 2021 at 20:56)</a>:</h4>
<p>repr(simd) is allowed with a dangerous nightly feature</p>



<a name="227335865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227335865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227335865">(Feb 22 2021 at 20:56)</a>:</h4>
<p>so you make like, a Vec&lt;Std140Mat4&gt; or whatever, and buffer that directly to the GPU</p>



<a name="227336098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227336098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227336098">(Feb 22 2021 at 20:58)</a>:</h4>
<blockquote>
<div class="codehilite"><pre><span></span><code>9. If the member is a structure, the base alignment of the structure is N, where
N is the largest base alignment value of any of its members, and rounded
up to the base alignment of a vec4. The individual members of this sub-
structure are then assigned offsets by applying this set of rules recursively,
where the base offset of the first member of the sub-structure is equal to the
aligned offset of the structure. The structure may have padding at the end;
the base offset of the member following the sub-structure is rounded up to
the next multiple of the base alignment of the structure.
</code></pre></div>

</blockquote>
<p>lovely.</p>



<a name="227336547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227336547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227336547">(Feb 22 2021 at 21:01)</a>:</h4>
<p><a href="https://giordi91.github.io/post/spirvvec3/">https://giordi91.github.io/post/spirvvec3/</a> <em>takes a drink</em></p>



<a name="227337894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227337894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227337894">(Feb 22 2021 at 21:11)</a>:</h4>
<p>this is why we need repr(simple)</p>



<a name="227337932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227337932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227337932">(Feb 22 2021 at 21:11)</a>:</h4>
<p>afaict with the scalar layout extension, a <code>vec3</code> would have an alignment of 4 (alignment of <code>f32</code>), not the 12 the article claims. As a rule of thumb, if you somehow get an alignment that isn't a power of 2, you should triple check, since that usually means you messed up somewhere.</p>



<a name="227337974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227337974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227337974">(Feb 22 2021 at 21:11)</a>:</h4>
<p>"just put it where i'm telling you to put it, and stop messing around"</p>



<a name="227338127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227338127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227338127">(Feb 22 2021 at 21:12)</a>:</h4>
<p>now of course, what would be neat but that the wider rust community would never accept (because we're a small language with a small standard library and not too many language features) is to just have <code>repr(glsl_std140)</code> and such built into the compiler</p>



<a name="227338168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227338168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227338168">(Feb 22 2021 at 21:12)</a>:</h4>
<p>maybe we need a <code>repr(custom)</code> that uses const-eval to calculate the layout, so users can write their own layout calculations</p>



<a name="227353953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227353953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227353953">(Feb 22 2021 at 22:59)</a>:</h4>
<p>So basically, from what I understand, from what I <strong>can</strong> understand now, the SIMT model is even more wild than I thought, GPUs have their own calling convention and ABI, and it doesn't necessarily play nice with C assumptions about how the world is organized, but is reasonably stable and you can program against it.</p>



<a name="227356834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227356834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227356834">(Feb 22 2021 at 23:23)</a>:</h4>
<p>oh I see... so it seems like the trick is that<br>
<code>struct Stuff (Vec3&lt;f32&gt;, f32)</code> can have a size and alignment of 16 bytes and strides normally every 16 bytes, but otherwise where the last f32 would go is padding?</p>



<a name="227357359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227357359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227357359">(Feb 22 2021 at 23:28)</a>:</h4>
<p>essentially</p>



<a name="227358836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227358836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227358836">(Feb 22 2021 at 23:43)</a>:</h4>
<p>Mmm. That sounds kind of similar to what Swift does, then.</p>



<a name="227359173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227359173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227359173">(Feb 22 2021 at 23:47)</a>:</h4>
<p>is there a way this could instead be modeled as some variation on #[repr(packed)]? it feels most reminiscent of that.</p>



<a name="227359219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227359219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227359219">(Feb 22 2021 at 23:47)</a>:</h4>
<p>except with... different alignment constraints.</p>



<a name="227362113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227362113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227362113">(Feb 23 2021 at 00:14)</a>:</h4>
<p><code>#[repr(packed)]</code> is like... "blow away all the rules" afaict. For these, it is still inherently rule-based, the algorithm is just custom.</p>



<a name="227364952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227364952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227364952">(Feb 23 2021 at 00:43)</a>:</h4>
<p>Hmm, i guess the similarity in my mind is they're both cases where bytes which would otherwise be padding bytes are used to store values.</p>



<a name="227365815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227365815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227365815">(Feb 23 2021 at 00:51)</a>:</h4>
<p>the padding is skipped over</p>



<a name="227366235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227366235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227366235">(Feb 23 2021 at 00:55)</a>:</h4>
<p>My understanding is the difference here is that you can still have padding, or maybe not, it just tries to tightly align things.</p>



<a name="227366756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227366756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227366756">(Feb 23 2021 at 01:01)</a>:</h4>
<p>yeah, in the same way that <code>repr(c) struct { u8, u16 }</code> has padding in it, the gpu layouts can end up with padding inside of a struct.</p>



<a name="227367869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227367869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227367869">(Feb 23 2021 at 01:12)</a>:</h4>
<p>i'm definitely not saying that it's the same as repr(packed), but it feels like there's a commonality there</p>



<a name="227390232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/227390232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#227390232">(Feb 23 2021 at 07:08)</a>:</h4>
<p>found out there's 4 different layout rules for GPU data lads.</p>



<a name="233860579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/GPUs%2C%20SIMD%2C%20and%20ABIs/near/233860579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs.html#233860579">(Apr 09 2021 at 17:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/GPUs.2C.20SIMD.2C.20and.20ABIs/near/227338168">said</a>:</p>
<blockquote>
<p>maybe we need a <code>repr(custom)</code> that uses const-eval to calculate the layout, so users can write their own layout calculations</p>
</blockquote>
<p>I think this is basically what we need in the lang on one level or another, yeah.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>